<html xmlns="http://www.w3.org/1999/xhtml"
	xmlns:ui="http://java.sun.com/jsf/facelets"
	xmlns:h="http://java.sun.com/jsf/html"
	xmlns:f="http://java.sun.com/jsf/core"
	xmlns:c="http://java.sun.com/jsp/jstl/core">

	<ui:composition template="generalTemplate.xhtml">
		<ui:define name="title">
		    <c:if test="#{!newsListBackingBean.archived}">
	    		Haberler
    		</c:if>
    		<c:if test="#{newsListBackingBean.archived}">
    			#{newsListBackingBean.currentArchive} · Haberler
    		</c:if>
		</ui:define>
		<ui:define name="content">
		
			<!-- Page Header -->
			<header class="jumbotron subhead">
	    		<h1>Haberler</h1>
	    		<c:if test="#{!newsListBackingBean.archived}">
	    			<p class="lead">... ve şimdi haberler.</p>
	    		</c:if>
	    		<c:if test="#{newsListBackingBean.archived}">
	    			<p class="lead">#{newsListBackingBean.currentArchive}nda gönderilmiş olan tüm haberler</p>
	    		</c:if>
	    	</header>
			<!-- /Page Header -->
			
			<div class="row">
				<div class="span9">
					<hr />
				    <c:if test="#{! empty newsListBackingBean.newsList}">
						<ui:repeat value="#{newsListBackingBean.paginator.model}" var="news">
					    	
					    	<!-- Header -->
							<header class="jumbotron subhead">
					    		<h2>
						    		<h:link style="color: black;" outcome="newsDetail">
						    			#{news.title}
						    			<f:param name="newsId" value="#{news.id}" />
						    		</h:link>
					    		</h2>			    		
					    		<em>
									<i class="icon-calendar"></i> <b> </b>
									<h:outputText value="#{news.publishedDate}">
										<f:convertDateTime type="date" timeStyle="short" pattern="dd.MM.yyyy" />
									</h:outputText> tarihinde gönderildi
								</em>
					  		</header>
					  		<!-- /Header -->
					  		<br />
							<p><h:outputText value="#{news.content}" escape="false" /></p>
							<br />
							<hr />
					    </ui:repeat>
					    	
					    <!-- Pagination -->
					    <h:form styleClass="pagination pagination-centered">
					    	<c:if test="#{!newsListBackingBean.archived}">
						    	<ul>
						    		<c:if test="#{newsListBackingBean.paginator.hasPrev()}">
										<li>
											<h:commandLink value="←" 
														style="color: black;"
														action="#{newsListBackingBean.paginator.prev}" />
										</li>
									</c:if>
									<li>
										<a href="#" style="color: black;">
											#{newsListBackingBean.paginator.pageIndex} / #{newsListBackingBean.paginator.pages}
										</a>
									</li>
									<c:if test="#{newsListBackingBean.paginator.hasNext()}">
										<li>
											<h:commandLink value="→"
														style="color: black;"
														action="#{newsListBackingBean.paginator.next}" />
										</li>
									</c:if>
									<h:inputHidden value="#{newsListBackingBean.paginator.pageIndex}" />
								</ul>
							</c:if>
							<c:if test="#{newsListBackingBean.archived}">
						    	<ul>
						    		<c:if test="#{newsListBackingBean.paginator.hasPrev()}">
										<li>
											<h:commandLink value="←" style="color: black;" action="#{newsListBackingBean.paginator.prev}">
												<f:param name="month" value="#{newsListBackingBean.month}" />
												<f:param name="year" value="#{newsListBackingBean.year}" />
											</h:commandLink>
										</li>
									</c:if>
									<li>
										<a href="#" style="color: black;">
											#{newsListBackingBean.paginator.pageIndex} / #{newsListBackingBean.paginator.pages}
										</a>
									</li>
									<c:if test="#{newsListBackingBean.paginator.hasNext()}">
										<li>
											<h:commandLink value="→" style="color: black;" action="#{newsListBackingBean.paginator.next}">
												<f:param name="month" value="#{newsListBackingBean.month}" />
												<f:param name="year" value="#{newsListBackingBean.year}" />
											</h:commandLink>
										</li>
									</c:if>
									<h:inputHidden value="#{newsListBackingBean.paginator.pageIndex}" />
								</ul>
							</c:if>
						</h:form>
						<!-- /Pagination -->
						
				    </c:if>
				    <c:if test="#{empty newsListBackingBean.newsList}">
				    	Yok ki...
				    </c:if>
				</div><!-- end of span9 -->
				<div class="span3">
					<hr />
				    <legend style="font-size: 13px; margin-bottom: 10px; font-weight: bold;">
						<i class="icon-folder-open"></i> Arşiv
					</legend>
				    <c:if test="#{! empty newsListBackingBean.monthsAsStringList}">
						<ul>
							<ui:repeat value="#{newsListBackingBean.monthsAsStringList}" var="month">
								<h:form style="margin: 0px; padding: 0px" rendered="#{newsListBackingBean.getNewsCountByMonth(month) != 0}">
							    	<li>
							    		<h:commandLink value="#{month}"
							    			action="#{newsListBackingBean.toArchiveAction(month)}" />
								    </li>
								    </h:form>
							</ui:repeat>
						</ul>
				    </c:if>
				    <c:if test="#{empty newsListBackingBean.monthsAsStringList}">
				    	Yok ki...
				    </c:if>
				</div><!-- end of span3 -->
		    </div><!-- end of row -->
		</ui:define>
	</ui:composition>
</html>